package com.clickpaas.workinghours.controller;

import com.clickpaas.workinghours.annotation.ControllerLog;
import com.clickpaas.workinghours.common.Response.ResponseResult;
import com.clickpaas.workinghours.entity.LeadEntity;
import com.clickpaas.workinghours.entity.TimeCardEntity;
import com.clickpaas.workinghours.service.ControllerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(description = "数据保存")
@RestController
@RequestMapping(value = "/change")
public class UpInsertController {
    @Resource
    ControllerService controllerService;

    @ApiOperation("插入TimeCard数据")
    @PostMapping(value = "/insertTimeCardInfo")
    @ControllerLog
    public ResponseResult insertTimeCardInfo(@ApiParam(value = "timeCardEntity")@RequestBody TimeCardEntity timeCardEntity) {

        return controllerService.insertTimeCardInfo(timeCardEntity);
    }

    @ApiOperation("批量插入TimeCard数据")
    @PostMapping(value = "/insertBatchTimeCardInfo")
    @ControllerLog
    public ResponseResult insertTimeCardInfo(@ApiParam(value = "timeCardEntity")@RequestBody List<TimeCardEntity> timeCardEntity) {

        return controllerService.insertBatchTimeCardInfo(timeCardEntity);
    }

    @ApiOperation("更新TimeCard数据")
    @PostMapping(value = "/updateTimeCardInfo")
    @ControllerLog
    public ResponseResult updateTimeCardInfo(@ApiParam(value = "timeCardEntity")@RequestBody TimeCardEntity timeCardEntity) {

        return controllerService.updateTimeCardInfo(timeCardEntity);
    }

    @ApiOperation("批量更新TimeCard数据(List)")
    @PostMapping(value = "/updateBatchTimeCardInfo")
    @ControllerLog
    public ResponseResult updateTimeCardInfo(@ApiParam(value = "timeCardEntity")@RequestBody List<TimeCardEntity> timeCardEntity) {

        return controllerService.updateBatchTimeCardInfo(timeCardEntity);
    }

    @ApiOperation("删除TimeCard数据")
    @PostMapping(value = "/deleteTimeCardInfo")
    @ControllerLog
    public ResponseResult deleteTimeCardInfo(@ApiParam(value = "timeCardEntity")@RequestBody TimeCardEntity timeCardEntity) {

        return controllerService.deleteTimeCardInfo(timeCardEntity);
    }

    @ApiOperation("更新Lead线索数据(租户接口以【Tenant】结尾)")
    @PostMapping(value = "/updateLeadInfoTenant")
    @ControllerLog
    public ResponseResult updateLeadInfo(@ApiParam(value = "leadEntity")@RequestBody LeadEntity leadEntity) {
        return controllerService.updateLeadInfo(leadEntity);
    }

}
